package com.work.straighttalk.presenter;

import com.work.straighttalk.bean.Contact;
import com.work.straighttalk.model.ContactsDBDataMImpl;
import com.work.straighttalk.model.i.LoadDBDataMI;
import com.work.straighttalk.presenter.i.LoadDataPresenterI;
import com.work.straighttalk.presenter.i.OnLoadFinishedListener;
import com.work.straighttalk.ui.i.BindDataVI;

import java.util.List;

/**
 * Created by 朱相卿 on 16/3/3.
 */
public class ContactsLoadDataPresenterImpl implements LoadDataPresenterI, OnLoadFinishedListener<List<Contact>> {
    private BindDataVI<List<Contact>> bindDataVI;
    private LoadDBDataMI loadDBDataMI;

    public ContactsLoadDataPresenterImpl(BindDataVI bindDataVI) {
        this.bindDataVI = bindDataVI;
        loadDBDataMI = new ContactsDBDataMImpl();
    }


    @Override
    public void onLoadSuccess(List<Contact> contacts) {
        bindDataVI.bindData(contacts);
    }

    @Override
    public void onLoadError() {
        loadData(null);
    }

    @Override
    public void loadData(Object o) {
        loadDBDataMI.loadData(null, this);
    }
}
